package main

import (
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
)

var ctx2 = context.Background()

var redisCli *redis.Client

func init() {
	redisCli = redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "", // no password set
		DB:       0,  // use default DB
	})
}

func GetRedisClient() *redis.Client {
	return redisCli
}

func main() {
	rdb := GetRedisClient()
	err := rdb.Set(ctx2, "zhangsan333", "123", 0).Err()
	if err != nil {
		panic(err)
	}

	val, err := rdb.Get(ctx2, "zhangsan333").Result()
	if err != nil {
		panic(err)
	}
	fmt.Println("val:", val)

}
